//
//  InterstitialAdBaseManager.h
//  GoogleUtilities
//
//  Created by neil on 2019/7/25.
//

#import <Foundation/Foundation.h>

#import <OSAttributionStatistics/AppsFlyerProxy.h>
@class InterstitialAdBaseManager;
@protocol InterstitialAdManagerDelegate <NSObject>

- (void)interstitialAdLoaded:(InterstitialAdBaseManager *_Nonnull)interstitialManager;
- (void)interstitialAdDidClose:(InterstitialAdBaseManager *_Nonnull)interstitialManager;
- (void)interstitialAdWillShow:(InterstitialAdBaseManager *_Nonnull)interstitialManager;

@end
typedef enum : NSInteger {
    InterstitialFailErrorNetworkError = 100,
    InterstitialFailErrorNoFill,
} InterstitialFailError;

typedef enum : NSUInteger {
    InterstitialEnumSplashEnd = 0,
    InterstitialEnumNextLevel,
    InterstitialEnumResume,
} InterstitialEnum;

@interface InterstitialAdBaseManager : NSObject

@property(nonatomic, assign)BOOL delayLoading;
@property(nonatomic, strong)NSMutableDictionary * _Nonnull logMap;
@property(nonatomic, strong)NSMutableDictionary * _Nonnull logErrorMap;
@property(nonatomic, weak)id<InterstitialAdManagerDelegate> _Nullable delegate;
@property(nonatomic, assign)InterstitialEnum type;

@property(nonatomic, assign)NSUInteger lastReloadAdTime;
@property(nonatomic, assign)NSInteger reloadTimes;
@property(nonatomic, assign)BOOL loadFailed;
@property(nonatomic, assign)BOOL failReasonNoNetwork;
//广告的id序号。
//@property(nonatomic, assign)NSInteger adIdIndex;

//延时加载，并且判断间隔时间 > 60s 再进行加载
- (void)delayToLoad:(NSInteger)delay;
//showRewardVideo 时判断not ready 时，重试加载
- (void)notReadyTryLoad;
//正常重试加载视频
- (void)normalReload:(NSInteger)delay;
//初始化，并开始加载s
- (instancetype _Nullable )initWithAdId:(NSString *_Nullable)adId
                                   type:(InterstitialEnum)type;
//直接返回内部 Interstitial的实现 。 abtest新功能里 调用此函数，会尝试重新加载广告
- (BOOL)isReady;
//- (BOOL)isReadyIfNoReLoadAd;
- (void)show;

- (void)presentFromRootViewController:(nonnull UIViewController *)rootViewController;
//收到网络的通知
- (void)netWorkReach;



///回调父类 统一处理， ad广告相关回调。
- (void)OSInterstitialDidReceiveAd:(InterstitialAdBaseManager *_Nullable)ad;
- (void)OSInterstitialDidDismissScreen:(InterstitialAdBaseManager *_Nullable)interstitial;
- (void)OSInterstitial:(InterstitialAdBaseManager *_Nullable)ad didFailToReceiveAdWithOSError:(NSError *_Nullable)osError originError:(NSError *_Nullable)originError;
- (void)OSInterstitialAdDidClick:(InterstitialAdBaseManager *_Nullable)ad;

@end

